#define _CRT_SECURE_NO_WARNINGS 1

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */
class Solution {
public:
    vector<int> decorateRecord(TreeNode* root)
    {
        if (root == nullptr) {
            return std::vector<int>();
        }

        std::vector<int> ret;
        std::queue<TreeNode*> q;
        q.push(root);

        while (!q.empty())
        {
            int levelSize = q.size();
            for (int i = 0; i < levelSize; ++i)
            {
                TreeNode* front = q.front();
                q.pop();
                ret.push_back(front->val);
                if (front->left)  q.push(front->left);
                if (front->right) q.push(front->right);
            }
        }

        return ret;
    }
};